fix(tsconfig): 根 tsconfig.node.json 加 noEmit,堵住全仓排放 - #3574
Merged
Conversation
根 `tsconfig.node.json` 既没有 `include`(默认编译整个仓库),又从 `tsconfig.base.json` 继承了 `declaration` / `declarationMap` / `sourceMap` 且没有 `outDir`。任何一次 `tsc -p tsconfig.node.json` 都会在每个源文件旁边 写出 .js / .d.ts / .map,实测 5,850 个,且全部不在 .gitignore 里。 objectui#3515 已经踩爆过一次:一条随手的 `git add -A` 吞进 402,729 行插入; 更糟的是排放出的 .js 带 JSX(来自 .tsx 输入),rolldown 会优先解析 `src/lib/utils.js` 而不是 `src/lib/utils.tsx`,于是 `@object-ui/components:build` 报出 165 个 "Unexpected JSX expression", 读起来像"你的改动弄坏了构建",实际与任何改动无关。 修法取最小静态防线:加 `"noEmit": true`。该文件是纯编辑器/引用配置, 全仓没有任何 script 运行它;它不被任何工程 `references`,所以 TS6310 不适用 ——`tsconfig.scripts.json` 与 `tsconfig.vitest-setup.json` 各自也是这个论证。 同时补一段文件头注释说明来由,避免下一个编辑者当作冗余删掉。 只改 emit,不改检查:该工程既有的 ~23.9k 错误原样保留(那份积压按 objectui#3515 的裁定不在本次范围内)。 Fixes #3549 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3549
问题
根
tsconfig.node.json既没有include(默认编译整个仓库),又从tsconfig.base.json继承了declaration/declarationMap/sourceMap且没有outDir。任何一次tsc -p tsconfig.node.json都会在每个源文件旁边写出.js/.d.ts/.map,而且这些形状全部不在.gitignore里。objectui#3515 已经实测踩爆过一次:一条随手的
git add -A吞进 402,729 行插入;更糟的是排放出的.js带 JSX(来自.tsx输入),rolldown 会优先解析src/lib/utils.js而不是src/lib/utils.tsx,于是@object-ui/components:build报出 165 个 "Unexpected JSX expression",读起来像"你的改动弄坏了构建",实际与任何改动无关。修法
取最小静态防线:给
compilerOptions加"noEmit": true,并补一段文件头注释说明来由(避免下一个编辑者当作冗余删掉)。选这条路而不是
.gitignore退路,是因为前置排查确认没有任何东西依赖它的 emit。全仓tsconfig.node.json的引用共 8 处,逐条落定:apps/console/package.json:48(tsc -b tsconfig.node.json --force)apps/console,解析到apps/console/tsconfig.node.jsonapps/console/tsconfig.json:28(references: ./tsconfig.node.json)apps/console/tsconfig.vitest-setup.json:14tsconfig.vitest-setup.json:89、tsconfig.scripts.json:15、tsconfig.scripts.json:96apps/console那个scripts/__tests__/vitest-setup-type-check.test.ts:17、:143turbo.json:26、.github/labeler.yml:80(tsconfig*.json)另外确认:根
tsconfig.json没有references数组,全仓所有 package 配置extends的都是../../tsconfig.json,没有任何工程extends或references根tsconfig.node.json—— 所以 TS6310(被引用工程不得noEmit)不适用。tsconfig.scripts.json与tsconfig.vitest-setup.json各自也是同一个论证(两者都是 standalone +noEmit: true)。逆向验证
方向是先预测后跑的。修前预测:排放物出现;修后预测:退出码记录、零新文件落盘、诊断数不变。
git status --porcelain条目??未跟踪)tsconfig.node.json本身)git clean -dn排放物构成:1,435 个
.js、1,434 个.ts(即.d.ts)、2,979 个.map,加 1 个.mjs/ 1 个.mts。抽查 issue 点名的四个路径,git check-ignore全部 NOT ignored,与 issue 的表格一致。两个数字与我的预测不符,都查清了,而且两个都是"修好了"的证据,不是回归:
退出码 1 → 2 不是变坏。 tsc 的约定是:
1= 报了错但仍生成了输出,2= 报了错且没有生成任何输出。退到 2 正是 emit 停止的机器可读确认。少掉的那 1 条诊断是 emit-only 诊断。 逐行 diff 后只有一条消失、零条新增:
TS2883 只在 TypeScript 必须写出
.d.ts却无法可移植地命名推断类型时才产生。关掉 emit 就不再写声明,该诊断自然不产生。也就是说:本 PR 只动 emit、不动检查,而唯一变化的诊断恰好属于 emit 本身。既有的 ~23.9k 错误原样保留(那份积压按 objectui#3515 的裁定不在本次范围内;issue 记录的 21,616 是当时的数,随 main 漂到了 23.9k)。同时确认
TS5053(declaration与noEmit并用)与TS6310均未出现 —— TS 6.0.3 下二者可共存。门禁
pnpm type-check:scriptspnpm type-check:vitest-setuppnpm check:control-bytespnpm type-check:coveragevitest run scripts/__tests__/{vitest-setup-type-check,scripts-type-check}.test.tstype-check:vitest-setup在全新 worktree 里初跑是红的(4 条 TS2882,@object-ui/components/fields/plugin-dashboard/plugin-grid找不到声明)。这是 CI 注释写明的^build前置缺失,不是本改动引起:把本 PR 的改动撤回到未修改的origin/main再跑,得到逐字相同的 4 条;补建这四个包及其依赖后,该门禁 EXIT=0。备注
content/docs/releases/。git clean -fdn先预演(5,850 条,零node_modules命中)再执行,清理后git status --porcelain与git clean -dn双双归零;没有用过git add -A。Generated by Claude Code